/**
 */
package proyecto.testcasetool.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import proyecto.testcasetool.ActionStep;
import proyecto.testcasetool.AlternativeFlow;
import proyecto.testcasetool.Step;
import proyecto.testcasetool.TestcasetoolPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Alternative Flow</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link proyecto.testcasetool.impl.AlternativeFlowImpl#getBranchStep <em>Branch Step</em>}</li>
 *   <li>{@link proyecto.testcasetool.impl.AlternativeFlowImpl#getJoinStep <em>Join Step</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class AlternativeFlowImpl extends ScenarioImpl implements AlternativeFlow {
	/**
	 * The cached value of the '{@link #getBranchStep() <em>Branch Step</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBranchStep()
	 * @generated
	 * @ordered
	 */
	protected ActionStep branchStep;

	/**
	 * The cached value of the '{@link #getJoinStep() <em>Join Step</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getJoinStep()
	 * @generated
	 * @ordered
	 */
	protected Step joinStep;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AlternativeFlowImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return TestcasetoolPackage.Literals.ALTERNATIVE_FLOW;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ActionStep getBranchStep() {
		if (branchStep != null && branchStep.eIsProxy()) {
			InternalEObject oldBranchStep = (InternalEObject)branchStep;
			branchStep = (ActionStep)eResolveProxy(oldBranchStep);
			if (branchStep != oldBranchStep) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, TestcasetoolPackage.ALTERNATIVE_FLOW__BRANCH_STEP, oldBranchStep, branchStep));
			}
		}
		return branchStep;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ActionStep basicGetBranchStep() {
		return branchStep;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetBranchStep(ActionStep newBranchStep, NotificationChain msgs) {
		ActionStep oldBranchStep = branchStep;
		branchStep = newBranchStep;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, TestcasetoolPackage.ALTERNATIVE_FLOW__BRANCH_STEP, oldBranchStep, newBranchStep);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setBranchStep(ActionStep newBranchStep) {
		if (newBranchStep != branchStep) {
			NotificationChain msgs = null;
			if (branchStep != null)
				msgs = ((InternalEObject)branchStep).eInverseRemove(this, TestcasetoolPackage.ACTION_STEP__ALTERNATIVE_FLOW, ActionStep.class, msgs);
			if (newBranchStep != null)
				msgs = ((InternalEObject)newBranchStep).eInverseAdd(this, TestcasetoolPackage.ACTION_STEP__ALTERNATIVE_FLOW, ActionStep.class, msgs);
			msgs = basicSetBranchStep(newBranchStep, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TestcasetoolPackage.ALTERNATIVE_FLOW__BRANCH_STEP, newBranchStep, newBranchStep));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Step getJoinStep() {
		if (joinStep != null && joinStep.eIsProxy()) {
			InternalEObject oldJoinStep = (InternalEObject)joinStep;
			joinStep = (Step)eResolveProxy(oldJoinStep);
			if (joinStep != oldJoinStep) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, TestcasetoolPackage.ALTERNATIVE_FLOW__JOIN_STEP, oldJoinStep, joinStep));
			}
		}
		return joinStep;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Step basicGetJoinStep() {
		return joinStep;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setJoinStep(Step newJoinStep) {
		Step oldJoinStep = joinStep;
		joinStep = newJoinStep;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, TestcasetoolPackage.ALTERNATIVE_FLOW__JOIN_STEP, oldJoinStep, joinStep));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case TestcasetoolPackage.ALTERNATIVE_FLOW__BRANCH_STEP:
				if (branchStep != null)
					msgs = ((InternalEObject)branchStep).eInverseRemove(this, TestcasetoolPackage.ACTION_STEP__ALTERNATIVE_FLOW, ActionStep.class, msgs);
				return basicSetBranchStep((ActionStep)otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case TestcasetoolPackage.ALTERNATIVE_FLOW__BRANCH_STEP:
				return basicSetBranchStep(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case TestcasetoolPackage.ALTERNATIVE_FLOW__BRANCH_STEP:
				if (resolve) return getBranchStep();
				return basicGetBranchStep();
			case TestcasetoolPackage.ALTERNATIVE_FLOW__JOIN_STEP:
				if (resolve) return getJoinStep();
				return basicGetJoinStep();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case TestcasetoolPackage.ALTERNATIVE_FLOW__BRANCH_STEP:
				setBranchStep((ActionStep)newValue);
				return;
			case TestcasetoolPackage.ALTERNATIVE_FLOW__JOIN_STEP:
				setJoinStep((Step)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case TestcasetoolPackage.ALTERNATIVE_FLOW__BRANCH_STEP:
				setBranchStep((ActionStep)null);
				return;
			case TestcasetoolPackage.ALTERNATIVE_FLOW__JOIN_STEP:
				setJoinStep((Step)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case TestcasetoolPackage.ALTERNATIVE_FLOW__BRANCH_STEP:
				return branchStep != null;
			case TestcasetoolPackage.ALTERNATIVE_FLOW__JOIN_STEP:
				return joinStep != null;
		}
		return super.eIsSet(featureID);
	}

} //AlternativeFlowImpl
